#ifndef TCPDATAREADER_H
#define TCPDATAREADER_H

#include <QtNetwork>
#include <QObject>

class TcpDataReader : public QObject
{
    Q_OBJECT
public:
    explicit TcpDataReader(QObject *parent = 0);

    void connectToServer();
    void disconnectFromServer();

    bool isConnected() const;
    int getNFrames();
    QByteArray popData();

signals:
    void dataReady();
    void connected(bool);

    void newData();

public slots:
    void on_closeConnection();
    void on_connectedToServer();
    void on_connectionClosedByServer();
    void updateData();


private:
    QTcpSocket tcpSocket;
    quint16 nextBlockSize;
    QMutex *dataMutex;
    QQueue<QByteArray> frames;
    bool bConnected;
};

#endif // TCPDATAREADER_H
